/*******************************************************************************
Last update: September 19, 2025
********************************************************************************/

/*******************************************************************************
Preliminaries
********************************************************************************/
cls
clear all
set more off

//Working directory
local wd "D:/Dropbox/Distinction Effect/Replication Package"
cd "`wd'"

if substr(c(pwd), -19, 19) == "Replication Package" {
	
	//User-written programs used are stored here
	adopath ++ Does/ado/

	//Load Author-written programs
	local filelist: dir "Does/Analysis/Programs/" files "*.do"
	foreach i of local filelist {
	  qui do "Does/Analysis/Programs/`i'"
	}
}
else {
	break
	dis in red "WARNING: Working directory is not Replication Package"
}

/******************************************************************************
Figures
******************************************************************************/

/*******************************************************************************
Figure 1: Effect of the National Distinction Award on Early-Career Earnings
********************************************************************************/
use "Data/Finals/Estimation Sample.dta", clear

rdrobust $Y score_sd, all vce(cluster year_area) kernel(epa) bwselect(mserd) p(1) covs(yarea_* $X $T)
global BW = e(h_l)
global PW = e(b_l)

tab award if score_sd >= 1
//Figure 1a
//Aggregate the information after 1
tempvar score
gen double `score' = score_sd
replace `score' = 1 if `score' >= 1 & `score' != .

tempvar y_demean
sum $Y
gen double `y_demean' = $Y - r(mean)
RDplot `y_demean' `score', z0(-3) z1(1) h(0.1) wid(0.2) degree(0) kernel(gaus) bw($BW) pw($PW) ylab(-0.1(0.05)0.3) xlab(-3(0.5)1 1"1+") ytitle("Log Earnings")
gr export "Results/Main/RDEarnings.png", replace wid(2000) hei(1500)
//Figure 1b
tempvar score
gen double `score' = score_sd 
replace `score' = 1 if `score' >= 1 & `score' != .

tempvar y_res
reghdfe $Y $X $T, absorb(year_area) res(`y_res')
RDplot `y_res' `score', z0(-3) z1(1) h(0.1) wid(0.2) degree(0) kernel(gaus) bw($BW) pw($PW) ylab(-0.1(0.05)0.3) xlab(-3(0.5)1 1"1+") ytitle("Residualized Log Earnings")
gr export "Results/Main/RDEarnings_res.png", replace wid(2000) hei(1500)

/********************************************************************************************
Figure 2: Robustness of the Effect of the National Distinction Award on Early-Career Earnings
*********************************************************************************************/
use "Results/Main/Data/RDRobust.dta",clear
	
gen main = 1 if bwmserd == 1 & model1 == 1 & covs == 1 & Areayear == 1

//Sort
gsort -beta
//Rank 
gen rank=_n
//Gen indicators and scatters
local scoff=" "
local scon=" "
local ind=-0.07
foreach var in nocovs Areayear Fieldyear scores covs model1 model2 bwmserd bwcerrd {
	cap gen i_`var' = `ind'
	local ind = `ind'-0.012

	if "`var'" == "bwcerrd" {
		global mlabel mlabel(bw) mlabpos(6) mlabcolor(black) mlabangle(0) mlabsize(tiny) mlabformat(%9.2fc)
	}
	else{
		global mlabel ""
	}

	local scoff = "`scoff' (scatter i_`var' rank, msize(vsmall) mcolor(gs14) $mlabel)" 
	local scon =" `scon' (scatter i_`var' rank if `var'==1, msize(vsmall) mcolor(black))"
		   
	if "`var'" == "model1" | "`var'" == "model2" {
		replace i_`var' = i_`var' - 0.03
	}
	if "`var'" == "bwmserd" | "`var'" == "bwcerrd" {
		replace i_`var' = i_`var' - 0.06
	}
}

# delimit ;
tw  (rspike u95 l95 rank, lcolor(gs5) lwidth(medthick))
	(rspike u90 l90 rank, lcolor(gs14) lwidth(medthick))
	(scatter beta rank if main==1, mcolor(white) msize(medium))
	(scatter beta rank if main!=1, mfcolor(gs12) mlcolor(black) msymbol(d) msize(medium) mlw(thin))
	`scoff' `scon'
	(scatter beta rank if main==1, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(medium) mlw(thin))
	,
	legend(order(4 "RD Estimates" 23 "Preferred Specification"  1 "95% CI" 2 "90% CI")
	region(lcolor(white)) pos(6) ring(1) rows(1) size(vsmall) symysize(small) symxsize(4pt))
	graphregion(fcolor(white) lcolor(white)) plotregion(fcolor(white) lcolor(white))
	xtitle(" ") ytitle(" ") yscale(noline) xscale(noline)
	ylab(0(0.05)0.3, format(%9.2fc) noticks nogrid angle(horizontal) labsize(small))
	yline(0, lp(shortdash) lcolor(black) lw(thin)) xlab("", noticks)  
;# delimit cr
global legend custom tickset(major) editstyle(tickstyle(textstyle(size(vsmall))))
gr_edit .yaxis1.add_ticks -0.05 `"Specification             "', $legend
gr_edit .yaxis1.add_ticks -0.07  `"No Controls   "', $legend
gr_edit .yaxis1.add_ticks -0.082 `"Area x Year FE   "', $legend
gr_edit .yaxis1.add_ticks -0.094 `"Field x Year FE   "', $legend
gr_edit .yaxis1.add_ticks -0.106 `"Test Scores   "', $legend
gr_edit .yaxis1.add_ticks -0.118 `"Covariates   "', $legend
gr_edit .yaxis1.add_ticks -0.14 `"Local Poly.                "', $legend
gr_edit .yaxis1.add_ticks -0.16 `"Linear            "', $legend
gr_edit .yaxis1.add_ticks -0.172 `"Quadratic      "', $legend
gr_edit .yaxis1.add_ticks -0.194 `"BW Method               "', $legend
gr_edit .yaxis1.add_ticks -0.214 `"MSE             "',$legend
gr_edit .yaxis1.add_ticks -0.226 `"CE                "', $legend
gr_edit .yaxis1.add_ticks -0.238 `"BW =            "', $legend
	
gr export "Results/Main/RDRobustness.png", replace wid(2000) hei(1500)

/*******************************************************************************
Figure 3: Heterogeneous Effects of the National Distinction Award
********************************************************************************/   
use "Results/Main/Data/RDHeterogeneity_cllg_rep_discrete.dta", clear

drop if Variable == 2
replace Variable = Variable - 1 if Variable > 1
replace Order = Order - 3 if Variable > 1

# delimit ;
local header1 (scatteri 0.39 0.25 0.39 2.75, recast(line) lcolor(black) lwidth(medium) 
	text(0.421 1.5 "Parents'", size(medsmall)) text(0.40 1.5 "Education", size(medsmall)) 
	text(0.38 0.95 "Non-", size(small)) text(0.365 0.95 "College", size(small)) 	
	text(0.37 2.05 "College", size(small))
	text(0.34 1 "(1)", size(small)) text(0.34 2 "(2)", size(small)) )
;# delimit cr

# delimit ;
local header2 (scatteri 0.39 3.25 0.39 5.75, recast(line) lcolor(black) lwidth(medium)
	text(0.421 4.5 "College", size(medsmall)) text(0.40 4.5 "Networks", size(medsmall))
	text(0.37 3.95 "Low", size(small)) text(0.37 5.05 "High", size(small))
	text(0.34 4 "(1)", size(small)) text(0.34 5 "(2)", size(small)) )
;# delimit cr

# delimit ;
local header3 (scatteri 0.39 6.25 0.39 8.75, recast(line) lcolor(black) lwidth(medium)
	text(0.41 7.5 "Gender", size(medsmall))
	text(0.37 7 "Female", size(small)) text(0.37 8 "Male", size(small))
	text(0.34 7 "(1)", size(small)) text(0.34 8 "(2)", size(small)) )
	(scatteri 0.35 0.6 0.35 1.4, recast(line) lcolor(black) lwidth(medium)) 
	(scatteri 0.35 1.6 0.35 2.4, recast(line) lcolor(black) lwidth(medium)) 
	(scatteri 0.35 3.6 0.35 4.4, recast(line) lcolor(black) lwidth(medium))
	(scatteri 0.35 4.6 0.35 5.4, recast(line) lcolor(black) lwidth(medium))
	(scatteri 0.35 6.6 0.35 7.4, recast(line) lcolor(black) lwidth(medium))
	(scatteri 0.35 7.6 0.35 8.4, recast(line) lcolor(black) lwidth(medium))
;# delimit cr
	
# delimit ;
tw (bar Coeff Order, barw(0.75) bfcolor("0 0 200%50") lcolor("0 0 200"))
   (rcap low95 up95 Order, color(black)) `header1' `header2' `header3'
   (scatter Coeff Order, msymbol(none) mlab(Coeff) mlabformat(%9.2f) mlabpos(2) mlabcolor(black))
   ,
	yti("Effect on Log Earnings" " ") xti("") graphregion(color(white))
	ylab(-0.10(0.05)0.4, angle(0) format(%9.2f) nogrid) yli(0, lcolor(black) lw(thin))
	xla(0(1)9, nolabels notick nogrid) xscale(noline)
	legend(pos(6) order(1 "RD Estimates" 2 "95% CI") region(color(white)) row(1))
;# delimit cr
gr export "Results/Main/Heterogeneity_cllg_rep_discrete_post.png", replace wid(2000) hei(1500)

/*******************************************************************************
Figure 4: Persistence of the Effect on First τ Observed Earnings
********************************************************************************/ 
use "Results/Main/Data/RDDynamic_3.dta", clear

gen low95 = RD_unbalanced - abs(invnormal(0.025))*SE_unbalanced
gen up95 = RD_unbalanced + abs(invnormal(0.025))*SE_unbalanced
gen low90 = RD_unbalanced - abs(invnormal(0.05))*SE_unbalanced
gen up90 = RD_unbalanced + abs(invnormal(0.05))*SE_unbalanced

# delimit ;
tw 	(rspike up95 low95 t, lcolor(gs5))
	(rspike up90 low90 t, lcolor(gs14))
	(scatter RD_unbalanced t, mfcolor(white) mlcolor(white) msymbol(O) msize(medium))
	(scatter RD_unbalanced t, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(medium) mlw(thin))
	,
	legend(pos(6) order(4 "RD Estimates" 1 "95% CI" 2 "90% CI") row(1) region(color(white)))
	graphregion(color(white)) plotregion(lcolor(black))
	yli(0, lp(shortdash) lcolor(black) lw(thin)) 
	ylab(-0.05(0.05)0.25, format(%9.2f) angle(0) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	xlab(1 "1ˢᵗ" 2 "2ⁿᵈ" 3 "3ʳᵈ" 4 "4ᵗʰ" 5 "5ᵗʰ", grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	xscale(range(0.5 5.5))
	yti("Effect on {bf:{it:{&tau}-th}}" "Observed Log of Earnings")
	xti(" " "{bf:{it:{&tau}-th}} Observed Log of Earnings")
;# delimit cr
gr_edit .xaxis1.edit_tick 6 0.5 `" "', custom tickset(major) editstyle(tickstyle(linestyle(width(none))))
gr_edit .xaxis1.edit_tick 7 5.5 `" "', custom tickset(major) editstyle(tickstyle(linestyle(width(none))))
gr export "Results/Main/RDDynamic_unbalanced_3.png", replace wid(2000) hei(1500)

/******************************************************************************
Tables
******************************************************************************/

/*******************************************************************************
Table 1: Effect of National Distinction Award on Early-Career Earnings
********************************************************************************/  
use "Results/Main/Data/RDMain_dta", clear
// Modify
gen n = _n
drop if n >= 1 & n<=7
replace n = 11 + n/19 if n>= 16
sort n

replace v1 = "National Award" if v1=="Robust"
foreach var of varlist v2-v7{
	replace `var' = "" if `var' == "No"
}

//Some Edits
replace v1 = "\addlinespace " + v1 if regexm(v1, "Area")

// Export
# delimit ;	
texsave v1-v7 using "Results/Main/RDMain.tex", 
headerlines("
& \multicolumn{6}{c}{Dependent Variable : Log Earnings}\\ \cline{2-7} \addlinespace
& (1) & (2) & (3) & (4) & (5) & (6)
") 
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix 
; # delimit cr
tex_edits, file("Results/Main/RDMain.tex")

/*******************************************************************************
Table 2: National Distinction Award and College Reputation
********************************************************************************/
use "Results/Main/Data/CollegeReputation_dta", clear
// Modify
drop in 1/7
replace v1 = "\addlinespace National Award" if v1=="Robust"

// Export
# delimit ;	
texsave v* using "Results/Main/CollegeReputation.tex",
headerlines("
& \multicolumn{6}{c}{Dependent Variable : Log Earnings} \\\cline{2-7} \addlinespace 
&  & \multicolumn{3}{c}{College Ranking :} & \multicolumn{2}{c}{Cross-sample Comparison :} \\\cline{3-5}\cline{6-7} \addlinespace 
& Full & & & & \multicolumn{2}{c}{Top 5 Non-awardees vs.}\\\cline{6-7}\addlinespace 
& \multirow{-2}{*}{Sample} & \multirow{-2}{*}{Top 5} & \multirow{-2}{*}{Top 6-20} & \multirow{-2}{*}{Below 20} & Top 6-20 & Below 20 \\ 
& & & & & Awardees & Awardees \\\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6}\cline{7-7}\addlinespace 
& (1) & (2) & (3) & (4) & (5) & (6)
")
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix 
; # delimit cr
// Final Edits
tex_edits, file("Results/Main/CollegeReputation.tex")

/*******************************************************************************
Table 3: Effects on the Allocation of Skills
********************************************************************************/
use "Results/Main/Data/FieldIndustry_dta", clear
// Modify
drop in 4/7
replace v1 = "National Award" if v1=="Robust"
drop in 1/2
// Export
# delimit ;	
texsave v1-v7 using "Results/Main/FieldIndustry.tex", 
headerlines("
& \multicolumn{6}{c}{Dependent Variable : } \\\cline{2-7} \addlinespace 
& \multicolumn{4}{c}{Field-Industry Match} & \multicolumn{2}{c}{Log Earnings} \\\cline{2-5}\cline{6-7} \addlinespace 
& \multirow{2}{*}{Full} & \multicolumn{3}{c}{College Ranking :} & \multicolumn{2}{c}{Type of Skills :} \\\cline{3-5}\cline{6-7} \addlinespace 
& Sample & Top 5 & Top 6-20 & Below 20 & Specific & Transferable \\ \addlinespace \cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6}\cline{7-7} \addlinespace 
& (1) & (2) & (3) & (4) & (5) & (6) 
") 
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix
; # delimit cr
// Final Edits
tex_edits, file("Results/Main/FieldIndustry.tex")

/*******************************************************************************
Table 4: Effect of Generic Skills Distinctions on Early-Career Earnings
********************************************************************************/
use "Results/Main/Data/GeneralSkills_dta", clear
// Modify
drop in 4/7
replace v1 = "National Award" if v1=="Robust"
drop in 1/2
// Export
# delimit ;	
texsave v* using "Results/Main/GeneralSkills.tex",
headerlines("
& \multicolumn{4}{c}{Dependent Variable : Log Earnings}\\ \cline{2-5} \addlinespace
& \multirow{2}{*}{Full} & \multicolumn{3}{c}{College Ranking :}\\ \cline{3-5}  \addlinespace
&  Sample & Top 5 & Top 6-20 & Below 20\\ \cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5} \addlinespace
& (1) & (2) & (3) & (4) 
") 
replace align(l@{\extracolsep{4pt}}cccc) location(h) frag nonames nofix 
; # delimit cr
// Final Edits
tex_edits, file("Results/Main/GeneralSkills.tex")

/*******************************************************************************
Table 5: Effects on Additional Accumulation of Skills
********************************************************************************/
use "Results/Main/Data/HumanCapital_sample_dta", clear
append using "Results/Main/Data/HumanCapital_top5_dta"
append using "Results/Main/Data/HumanCapital_top20_dta"
append using "Results/Main/Data/HumanCapital_above20_dta"
gen n = _n
drop if n >= 4 & n <= 7 | n >= 19 & n <= 22 | n >= 34 & n <= 37 | n >= 49 & n <= 52
drop if n >= 13 & n <= 14 | n >= 28 & n <= 29 | n >= 43 & n <= 44 | n >= 58 & n <= 59
drop if n >= 1 & n <= 2 | n >= 16 & n <= 17 | n >= 31 & n <= 32 | n >= 46 & n <= 47 
replace v1 = "National Award" if v1=="Robust"
replace v1 = "\addlinespace \textit{Full Sample}" if n == 3
replace v1 = "\hline \addlinespace \textit{Top 5}" if n == 18
replace v1 = "\hline \addlinespace \textit{Top 6-20}" if n == 33
replace v1 = "\hline \addlinespace \textit{Below Top 20}" if n == 48
replace v1 = "\hspace{8pt} " + v1 if !regexm(v1, "addlinespace") & v1 != ""

// Export
# delimit ;	
texsave v* using "Results/Main/HumanCapital_CllgRep2.tex",
headerlines("
& \multicolumn{5}{c}{Dependent Variable : } \\\cline{2-6} \addlinespace 
& \multirow{2}{*}{Months to} & \multicolumn{3}{c}{Number of Subjects by Graduation} & \multirow{2}{*}{Graduate} \\\cline{3-5} \addlinespace
& College & Total & \multicolumn{2}{c}{Registered After Exam:} & Education \\\cline{4-5} \addlinespace
& \multirow{-2}{*}{Grad. Date} & \multirow{-2}{*}{Registered} & Total & Passed & \\\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6} \addlinespace
& (1) & (2) & (3) & (4) & (5)
") 
replace align(l@{\extracolsep{4pt}}ccccc) location(h) frag nonames nofix
; # delimit cr
tex_edits, file("Results/Main/HumanCapital_CllgRep2.tex")

/*******************************************************************************************
Table 6: Effects on the Probability of Switching Jobs and Job Characteristics After Switching
********************************************************************************************/
use "Results/Main/Data/Job-Ladder_P1_sample_CIIU_3_dta", clear
append using "Results/Main/Data/Job-Ladder_P1_top5_CIIU_3_dta"
append using "Results/Main/Data/Job-Ladder_P1_top20_CIIU_3_dta"
append using "Results/Main/Data/Job-Ladder_P1_above20_CIIU_3_dta"
gen n = _n
drop if n >= 4 & n <= 7 | n >= 19 & n <= 22 | n >= 34 & n <= 37 | n >= 49 & n <= 52
drop if n >= 13 & n <= 14 | n >= 28 & n <= 29 | n >= 43 & n <= 44 | n >= 58 & n <= 59
drop if n >= 1 & n <= 2 | n >= 16 & n <= 17 | n >= 31 & n <= 32 | n >= 46 & n <= 47
replace v1 = "National Award" if v1=="Robust"

replace v1 = "\addlinespace \textit{Full Sample}" if n == 3
replace v1 = "\hline \addlinespace \textit{Top 5}" if n == 18
replace v1 = "\hline \addlinespace \textit{Top 6-20}" if n == 33
replace v1 = "\hline \addlinespace \textit{Below Top 20}" if n == 48
replace v1 = "\hspace{8pt} " + v1 if !regexm(v1, "addlinespace") & v1 != ""

// Export
# delimit ;	
texsave v* using "Results/Main/Job-Ladder_CIIU_3.tex",
headerlines("
& \multicolumn{7}{c}{Dependent Variable : } \\\cline{2-8} \addlinespace
& \multicolumn{3}{c}{\multirow{2}{*}{Log Earnings accross time, $\tau$}} & Worker Switch & \multicolumn{3}{c}{Employer's Wage Premium Across Time, $\tau$} \\\cline{6-8} \addlinespace
&&&& \multirow{-2}{*}{Employers} & First Employer & \multicolumn{2}{c}{$\Delta$ Future Employers} \\\cline{2-4}\cline{5-5}\cline{6-6}\cline{7-8} \addlinespace 
& $\tau$ = 1 & $\tau$ = 2 & $\tau$ = 3 & Once or Twice & $\tau$ = 1 & $\tau = 2$ & $\tau = 3$ \\\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6}\cline{7-7}\cline{8-8} \addlinespace 
& (1) & (2) & (3) & (4) & (5) & (6) & (7)
") 
replace align(l@{\extracolsep{4pt}}ccccccc) location(h) frag nonames nofix 
; # delimit cr
tex_edits, file("Results/Main/Job-Ladder_CIIU_3.tex")

/******************************************************************************
Appendix Figures
******************************************************************************/
/***************************************************************************************************
Appendix Figure A.1: Probability of Taking the College Exit Exam as a Function of College Reputation
****************************************************************************************************/
use "Data\Finals\SProEligible.dta", clear
rename ies cllg_code 
merge m:1 cllg_code using "Data/Finals/CollegeReputation.dta"
keep if _merge == 3
drop _merge

gen n = 1
collapse (mean) spa_spro cllg_reputation (sum) n, by(program_code cllg_code cllg_prv)
drop if n < 5

//Full Sample
egen N = total(n)
gen iw = n/N
reg spa_spro cllg_reputation, cluster(cllg_code)
local b = string(_b[cllg_reputation], "%9.4f")
local se = string(_se[cllg_reputation], "%9.4f")

# delimit ;
tw  (scatter spa_spro cllg_reputation if cllg_prv == 1, ms(o) mlcolor("0 0 200") mfcolor("0 0 200%50"))
(scatter spa_spro cllg_reputation if cllg_prv == 0, ms(d) mlcolor(gs6) mfcolor(gs6%50))
(lfit spa_spro cllg_reputation, lcolor(black))
,
graphregion(color(white)) plotregion(lcolor(black)) xli(0, lcolor(black) lp(solid) lw(thin))
ylab(0(0.1)1, format(%9.1f) angle(horizontal) labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
xlab(40(10)100, format(%9.0f) labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
xti(" " "College Reputation")
yti("Probability of Taking College Exit Exam" " ") legend(pos(6) row(1) order(1 "Private" 2 "Public") region(color(white)))
text(0.05 94 "`b' (`se')", place(c) fc(white) box margin(l t+1 b+1) size(small))
; # delimit cr

gr export "Results/Online Appendix/ProbSaberProbyCllg.png", replace wid(2000) hei(1500)

/***************************************************************************************************
Appendix Figure A.2: Relationship Between Students' Fields of Study
and Specific Exams
****************************************************************************************************/

* Run "4. AFigure Field of Study - Specific Exam"

/***************************************************************************************************
Appendix Figure A.3: Distinction Recipients by Field of Study and Exam Year
****************************************************************************************************/
use "Results/Online Appendix/Data/AwardeesbyExamYear.dta", clear

gsort -total09
gen rank = _n
labmask rank, values(exam_field)
# delimit ;		
twoway 
	(bar total09 rank, bcolor(black) barw(0.80)) (bar total08 rank, bcolor(gs4) barw(0.80))
	(bar total07 rank, bcolor(gs8) barw(0.80)) (bar total06 rank, bcolor(gs12) barw(0.80)) 
	||
	(scatter share2006 rank, yaxis(2) msize(small) ms(O) mlcolor(blue) mlw(vthin) mfcolor(blue%40))
	(scatter share2007 rank, yaxis(2) msize(small) ms(t) mlcolor(red) mlw(vthin) mfcolor(red%40))
	(scatter share2008 rank, yaxis(2) ms(X) mlcolor(gold) mlw(thin))
	(scatter share2009 rank, yaxis(2) msize(small) ms(s) mlcolor(midgreen) mlw(vthin) mfcolor(midgreen%40)) 
	//(scatter total09 rank, mlabel(total09) msymbol(none) mlabpos(12) mlabsize(1.5) mlabcolor(black))
	,
	graphregion(color(white)) plotregion(lcolor(black))
	xlab(1(1)45, angle(90) noticks labels labsize(7pt) valuelabel)
	ylab(0(20)200, angle(0) labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
	ylab(0(2)10, angle(0) axis(2)) 
	xti("") yti("Number of Awardees (bars)" " ") yti("% Awardees (markers)", axis(2)) 
	legend(
	pos(6) order(5 "2006:" 4 "" 6 " 2007:" 3 "" 7 " 2008:" 2 "" 8 " 2009:" 1 "")  
	textfirst region(lcolor(white)) col(4) symysize(small) symxsize(8pt) colgap(1pt)
	)
;# delimit cr
gr export "Results/Online Appendix/AwardeesbyExamYear.png", replace  wid(1000) hei(700)	

/***************************************************************************************************
Appendix Figure A.4: Google Trends Interest for National Distinction Award
****************************************************************************************************/
insheet using "Data\Originals\Other/GoogleTrends_MejoresEcaes.csv", clear	
gen date = date(week, "MDY")
format date %td
gen t = _n
gen year = year(date)
labmask t, values(year)
	
# delimit ;
twoway (line mejoresecaescolombia t), 	
		graphregion(color(white)) plotregion(lcolor(black))
		xlab(1 54 106 158, labsize(medsmall) valuelabel grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
		ylab(0(10)100, format(%9.0fc) angle(zero) labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
		yti("Interest Over Time")
		xti(" " "Year") 
; # delimit cr
gr export "Results/Online Appendix/GoogleTrends.png", replace wid(2000) hei(1500)

/***************************************************************************************************
Appendix Figure A.5: Sample Report of Performance in the College Exit Exam
****************************************************************************************************/

* Example of a report card of performance of a student who took the economics field exam in 2009.

/***************************************************************************************************
Appendix Figure A.6: Placebo Tests and Differences in Earnings Between Contiguous Percentiles
****************************************************************************************************/
//Appendix Figure A.6 a
use "Results/Online Appendix/Data/PlaceboTest.dta", clear

gen low95 = RD - abs(invnormal(0.025))*SE
gen up95 = RD + abs(invnormal(0.025))*SE
gen low90 = RD - abs(invnormal(0.05))*SE
gen up90 = RD + abs(invnormal(0.05))*SE

# delimit ;
tw 	(rspike up95 low95 percentile, lcolor(gs5))
	(rspike up90 low90 percentile, lcolor(gs14))
	(scatter RD percentile, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(vsmall) mlw(thin))
	,
	graphregion(color(white)) plotregion(lcolor(black))
	xlab(1(1)6, grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
	ylab(-0.25(0.05)0.25, format(%9.2fc) angle(0) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	yli(0, lcolor(black) lp(solid) lw(thin)) xlab(0(10)100)
	legend(pos(6) order(3 "RD Estimates" 1 "95% CI" 2 "90% CI") row(1) region(color(white)))
	yti("Effect on Log Earnings" "Placebo Cutoff at Percentile {it:q}") xti(" " "Percentiles Field-Specific Exam ({it:q})")
; # delimit cr
gr export "Results/Online Appendix/PlaceboTest.png", replace wid(2000) hei(1500)

//Appendix Figure A.6 b
use "Results/Online Appendix/Data/EarningsDiffPlacebo.dta", clear

gen low95 = coeff - abs(invt(df, 0.025))*se
gen up95 = coeff + abs(invt(df, 0.025))*se
gen low90 = coeff - abs(invt(df, 0.05))*se
gen up90 = coeff + abs(invt(df, 0.05))*se
		
# delimit ;
tw 	(rspike up95 low95 percentile, lcolor(gs5))
	(rspike up90 low90 percentile, lcolor(gs14))
	(scatter coeff percentile, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(vsmall) mlw(thin))
	,
	graphregion(color(white)) plotregion(lcolor(black))
	xlab(1(1)6, grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
	ylab(-0.25(0.05)0.25, format(%9.2fc) angle(0) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	yli(0, lcolor(black) lp(solid) lw(thin)) xlab(0(10)100)
	legend(pos(6) order(3 "OLS Estimates" 1 "95% CI" 2 "90% CI") row(1) region(color(white)))
	yti("Difference in Log Earnings" "Percentiles {it:q} and {it:q-1}") xti(" " "Percentiles Field-Specific Test ({it:q})")		
; # delimit cr
gr export "Results/Online Appendix/EarningsDiffPlacebo.png", replace wid(2000) hei(1500)

/*********************************************************************************************
Appendix Figure C.1: Density Smoothness Around the Cutoff of the National Distinction Award
**********************************************************************************************/
//Appendix Figure C.1 a
use "Data/Finals/Estimation Sample.dta", clear

# delimit ;
tw  (kdensity score_sd if score_sd >= -8, lcolor("0 0 200") lw(thin))
	(histogram score_sd if score_sd >= -8, w(0.1) lw(thin) lcolor("0 0 200%50") fcolor("0 0 200%20"))
	,
	graphregion(color(white)) plotregion(lcolor(black)) xli(0, lcolor(black) lp(solid) lw(thin))
	ylab(0(0.05)0.4, format(%9.2f) angle(horizontal) labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
	xlab(-8(1)3, format(%9.1fc) labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	xti(" " "Distance to National Distinction Award cutoff ({&sigma})")
	yti("Density" " ") legend(off)	
; # delimit cr
gr export "Results/Online Appendix/NormalizedDensity.png", replace wid(2000) hei(1500)

//Appendix Figure C.1 b
use "Results/Online Appendix/Data/ManipulationTest.dta", clear

local i = 1
foreach year of numlist 2006(1)2009 {
qui count if Calonico_p_val`year' != .
local N`i' = r(N)
qui count if Calonico_p_val`year' < 0.05
local n`i' = r(N)
local i = `i'+1
}
dis `n1' + `n2' + `n3' + `n4'
dis `N1' + `N2' + `N3' + `N4'
dis (`n1' + `n2' + `n3' + `n4')/(`N1' + `N2' + `N3' + `N4')

keep Calonico_p_val* exam_field
sort exam_field
gen order = _n
labmask order, values(exam_field)
missings dropobs Calonico_p_val*, force
sum order
local max = r(max)

# delimit ;
tw  (scatter Calonico_p_val2006 order, mcolor(black*0.75) ms(x) msize(small))
	(scatter Calonico_p_val2007 order, mcolor(black*0.75) ms(oh) msize(small))
	(scatter Calonico_p_val2008 order, mcolor(black*0.75) ms(d) msize(small))
	(scatter Calonico_p_val2009 order, mcolor(black*0.75) ms(o) msize(small))
	,
	graphregion(color(white)) plotregion(lcolor(black))
	ylab(0(0.2)1, format(%9.2f) angle(horizontal) labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
	xlab(1(1)`max', labels labsize(small) angle(90) valuelabel)
	yli(0.05, lcolor(black) lp(solid) lw(thin))
	legend(pos(6) order(1 "2006" 2 "2007" 3 "2008" 4 "2009") region(color(white)) row(1))
	yti("P-value" " ") xti("") 
; # delimit cr
gr export "Results/Online Appendix/ManipulationTest.png", replace wid(2000) hei(1500)

/***************************************************************************************************
Appendix Figure C.2: Field-Specific Exam Scores and RD First Stage
****************************************************************************************************/
//Appendix Figure C.2 a
use "Data/Finals/Estimation Sample.dta", clear

//Store all Tresholds
levelsof score_cutoff, local(cutoffs)
local tresholds = " "
foreach c of local cutoffs {
dis `c'
local tresholds = "`tresholds' xli(`c', lcolor(black) lp(dot))"
}

tempvar score
sum spro_puntaje
gen `score' = spro_puntaje if spro_puntaje >= r(mean)-7*r(sd)

//Plot Density with all Tresholds
# delimit ;
tw  (kdensity `score' , lcolor("0 0 200") lw(thin))
	(histogram `score', w(1) lcolor("0 0 200%50") lw(thin) fcolor("0 0 200%20"))
	,
	`tresholds' 
	ylab(0(0.01)0.05, format(%9.2f) angle(horizontal) labsize(medsmall) glwidth(none) nogextend)
	xlab(30(10)160, format(%9.0f) labsize(medsmall) glwidth(none) nogextend)	
	graphregion(color(white)) plotregion(lcolor(black)) 
	xti(" " "Field-Specific Score at College Exit Exam") 
	yti("Density" " ") legend(off)
	; # delimit cr
gr export "Results/Online Appendix/ScoresDensity.png", replace wid(2000) hei(1500)

//Appendix Figure C.2 b

use "Data/Finals/Estimation Sample.dta", clear

tempvar running prob_award
gen double `running' = .
gen double `prob_award' = .
local h = 0.1
local n = 1
qui foreach i of numlist -3(`h')1 {
	qui replace `running' = `i' in `n'
	if `i' != 0 {
	sum award if score_sd >= `i' - `h'/2 & score_sd < `i' + `h'/2    	    
	}
	else {
	sum award if score_sd >= 0 & score_sd < `h'/2	    
	}
	qui replace `prob_award' = r(mean) in `n'
	local n = `n' + 1
} 

# delimit ;
tw (scatter `prob_award' `running' , mfcolor(gs10) mlcolor(black) mlw(thin) msize(medsmall) )
	,
	graphregion(color(white)) plotregion(lcolor(black)) xli(0, lcolor(black) lp(solid) lw(thin))
	ylab(0(0.1)1, format(%9.1f) angle(horizontal) labsize(medsmall) grid glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
	xlab(-3(0.5)1, format(%9.1fc) labsize(medsmall) grid glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	xti(" " "Distance to National Distinction Award cutoff ({&sigma})") 
	yti("Pr( Winning National Award )" " ") legend(off)
;# delimit cr
gr export "Results/Online Appendix/RDProbDistinction_scores.png", replace  wid(700) hei(500)

/*************************************************************************************
Appendix Figure C.3: Covariate Balance Around the Cutoff of the National Distinction Award
**************************************************************************************/
use "Results/Online Appendix/Data/RDCovContinuity_std.dta", clear

replace varname = subinstr(varname, "'s", "", .)
gen aux1 = RD in 1/6
gen aux2 = RD in 7/9
gen aux3 = RD in 10/12
gen aux4 = RD in 13
gsort -aux4 -aux3 -aux2 -aux1 
drop aux*

gen variable = _n
replace Mean = round(Mean, 0.001)
replace P_value = round(P_value, 0.001)
tostring Mean P_value, replace format(%9.2f) force
replace Mean = "0" + Mean if strpos(Mean, ".") == 1
replace varname = varname + ",  P-val. = " + P_value 
labmask variable, values(varname)
gen l95 = RD - abs(invnormal(0.025))*SE
gen u95 = RD + abs(invnormal(0.025))*SE
gen l90 = RD - abs(invnormal(0.05))*SE
gen u90 = RD + abs(invnormal(0.05))*SE

# delimit ;
twoway  (rspike u95 l95 variable, horizontal lcolor(gs5) lw(medthick))
	(rspike u90 l90 variable, horizontal lcolor(gs14) lw(medthick))
	(scatter variable RD, color(white) msymbol(O) msize(medium) mlw(thin) sort)
	(scatter variable RD, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(medium) mlw(thin) sort)
	,
	legend(off) graphregion(color(white))
	xlab(-1(0.2)1, format(%9.1fc) labsize(small)) xline(0, lw(thin) lcolor(black))
	ylab(1(1)13, noticks valuelabel angle(zero) nogrid labsize(7.5pt)) yscale(noline)
	yti("") xti(" " "Difference between Awardees and Non-awardees" "(Regression Discontinuity Estimates)", size(small)) 
; # delimit cr
gr export "Results/Online Appendix/RDCovContinuity_std.png", replace wid(2200) hei(1500)

/***************************************************************************************************
Appendix Figures C.4 & C.5: Continuity in Pretreatment Covariates
****************************************************************************************************/
use "Data/Finals/Estimation Sample.dta", clear

rdrobust $Y score_sd, all vce(cluster year_area) kernel(epa) bwselect(cerrd) p(1) covs(yarea_* $X $T)
global BW = e(h_l)
global PW = e(b_l)

global Covs female age low_SES high_SES meduc_cllg feduc_cllg working main_city cllg_prv top5 num_semesters sb11score reading english
keep $Covs score_sd yarea_* year_area cllg_reputation_sd

//Plots
tempvar score
gen double `score' = score_sd
replace `score' = 1.19 if `score' >= 1.2 & `score' != .

foreach x of varlist meduc_cllg feduc_cllg female cllg_prv top5 working high_SES {
    local y_title = "`: variable label `x''"
	
	RDplot `x' `score', z0(-3) z1(1.2) h(0.1) wid(0.1) degree(1) kernel(gaus) bw($BW) pw($PW) ylab(0(0.1)0.9) xlab(-3(0.5)1) yformat(%9.1fc) ytitle("Pr( `y_title' )")
	gr export "Results/Online Appendix/RD`x'.png", replace wid(2000) hei(1500)
}

RDplot age `score', z0(-3) z1(1.2) h(0.1) wid(0.1) degree(1) kernel(gaus) bw($BW) pw($PW) ylab(22(0.5)27) xlab(-3(0.5)1) yformat(%9.1fc) ytitle("Age at Test Date")
gr export "Results/Online Appendix/RDage.png", replace wid(2000) hei(1500)

RDplot reading `score', z0(-3) z1(1.2) h(0.1) wid(0.1) degree(1) kernel(gaus) bw($BW) pw($PW) ylab(-0.25(0.25)2.5) xlab(-3(0.5)1) ytitle("College Exit Exam: Reading Score ({&sigma})")
gr export "Results/Online Appendix/RDreading.png", replace wid(2000) hei(1500)

RDplot english `score', z0(-3) z1(1.2) h(0.1) wid(0.1) degree(1) kernel(gaus) bw($BW) pw($PW) ylab(-0.25(0.25)2.5) xlab(-3(0.5)1) ytitle("College Exit Exam: English Score ({&sigma})")
gr export "Results/Online Appendix/RDenglish.png", replace wid(2000) hei(1500)

RDplot sb11score `score', z0(-3) z1(1.2) h(0.1) wid(0.1) degree(1) kernel(gaus) bw($BW) pw($PW) ylab(-0.25(0.25)2.5) xlab(-3(0.5)1) ytitle("High School Exit Exam: Overall Score ({&sigma})")
gr export "Results/Online Appendix/RDsb11score.png", replace wid(2000) hei(1500)

RDplot sb11score `score', z0(-3) z1(1.2) h(0.1) wid(0.1) degree(1) kernel(gaus) bw($BW) pw($PW) ylab(-0.25(0.25)2.5) xlab(-3(0.5)1) ytitle("High School Exit Exam: Overall Score ({&sigma})")
gr export "Results/Online Appendix/RDsb11score.png", replace wid(2000) hei(1500)

RDplot cllg_reputation_sd `score', z0(-3) z1(1.2) h(0.1) wid(0.1) degree(1) kernel(gaus) bw($BW) pw($PW) ylab(65(5)95) yformat(%9.0f) xlab(-3(0.5)1) ytitle("College Reputation")
gr export "Results/Online Appendix/RDcllgreputation.png", replace wid(2000) hei(1500)

/*******************************************************************************
Appendix Figure C.6: Sample Selection Around the Cutoff of the National Distinction Award
********************************************************************************/
//Appendix Figure C.6 a
use "Results/Online Appendix/Data/RDBADegree.dta", clear

gen l95 = RD - abs(invnormal(0.025))*SE
gen u95 = RD + abs(invnormal(0.025))*SE
gen l90 = RD - abs(invnormal(0.05))*SE
gen u90 = RD + abs(invnormal(0.05))*SE
gen t = _n + 2006

# delimit ;
twoway (rspike u95 l95 t, lcolor(gs5) lwidth(medthick)) (rspike u90 l90 t, lcolor(gs14) lwidth(medthick))
	(scatter RD t, mcolor(white) msize(medium)) 
	(scatter RD t, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(medium) mlw(thin)) 
	,
	legend(pos(6) order(4 "RD Estimates" 1 "95% CI" 2 "90% CI") row(1) region(color(white)))
	graphregion(color(white)) plotregion(lcolor(black))
	xlab(2007(1)2016 2006.5" " 2016.5" ", labsize(small) valuelabel grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
	ylab(-0.15(0.05)0.15, format(%9.2fc) angle(zero) labsize(small) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	yti("Pr( Graduating from College in {bf:{it: t }} )")
	xti(" " "Year ({bf:{it: t }})") 
	yline(0, lw(thin) lcolor(black) lp(solid))
; # delimit cr
gr_edit .xaxis1.edit_tick 11 2006.5 `" "', custom tickset(major) editstyle(tickstyle(linestyle(width(none))))
gr_edit .xaxis1.edit_tick 12 2016.5 `" "', custom tickset(major) editstyle(tickstyle(linestyle(width(none))))
gr export "Results/Online Appendix/RDBADegree.png", replace wid(2000) hei(1500)

//Appendix Figure C.6 b
use "Results/Online Appendix/Data/RDFormalWork.dta", clear

gen l95 = RD - abs(invnormal(0.025))*SE
gen u95 = RD + abs(invnormal(0.025))*SE
gen l90 = RD - abs(invnormal(0.05))*SE
gen u90 = RD + abs(invnormal(0.05))*SE
gen t = _n + 2007

# delimit ;
twoway (rspike u95 l95 t, lcolor(gs5) lwidth(medthick)) (rspike u90 l90 t, lcolor(gs14) lwidth(medthick))
	(scatter RD t, mcolor(white) msize(medium)) 
	(scatter RD t, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(medium) mlw(thin)) 
	,
	legend(pos(6) order(3 "RD Estimates" 1 "95% CI" 2 "90% CI") row(1) region(color(white)))
	graphregion(color(white)) plotregion(lcolor(black))
	xlab(2008(1)2016 2007.5" " 2016.5" ", labsize(small) valuelabel grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	ylab(-0.15(0.05)0.15, format(%9.2fc) angle(zero) labsize(small) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
	yti("Pr( Observe Earnings in {bf:{it: t }} )") 
	xti(" " "Year ({bf:{it: t }})")
	yline(0, lw(thin) lcolor(black) lp(solid))
; # delimit cr
gr_edit .xaxis1.edit_tick 10 2007.5 `" "', custom tickset(major) editstyle(tickstyle(linestyle(width(none))))
gr_edit .xaxis1.edit_tick 11 2016.5 `" "', custom tickset(major) editstyle(tickstyle(linestyle(width(none))))
gr export "Results/Online Appendix/RDFormalWork.png", replace wid(2000) hei(1500)

/***************************************************************************************************
Appendix Figure C.7: Graduation Rates among Saber Pro Test Takers
****************************************************************************************************/
use "Results/Online Appendix/Data/GraduationRates.dta", clear	

//Appendix Figure C.7 a
# delimit ;
twoway (connected sh grad_year if exam_year == 2006, ms(o) mcolor(gs10) lc(gs10))
	(connected sh grad_year if exam_year == 2007, ms(d) mcolor(gs8) lc(gs8))
	(connected sh grad_year if exam_year == 2008, ms(t) mcolor(gs6) lc(gs6))
	(connected sh grad_year if exam_year == 2009, ms(s) mcolor(gs4) lc(gs4))
	,
	graphregion(color(white)) plotregion(lcolor(black))
	ylab(0(0.1)1, angle(0) format(%9.1fc) labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
	xlab(2006(1)2016, labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	legend(pos(6) order(1 "2006" 2 "2007" 3 "2008" 4 "2009") region(color(white)) row(1))
	yti("Share of College Graduates" " ") xti(" " "Year of Graduation")
;# delimit cr
gr export "Results/Online Appendix/GraduationRates.png", replace wid(2000) hei(1500)

//AAppendix Figure C.7 b
# delimit ;
twoway (connected sh_awardees grad_year if exam_year == 2006, ms(o) mcolor(gs10) lc(gs10))
	(connected sh_awardees grad_year if exam_year == 2007, ms(d) mcolor(gs8) lc(gs8))
	(connected sh_awardees grad_year if exam_year == 2008, ms(t) mcolor(gs6) lc(gs6))
	(connected sh_awardees grad_year if exam_year == 2009, ms(s) mcolor(gs4) lc(gs4))
	,
	graphregion(color(white)) plotregion(lcolor(black))
	ylab(0(0.1)1, angle(0) format(%9.1fc) labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
	xlab(2006(1)2016, labsize(medsmall) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	legend(pos(6) order(1 "2006" 2 "2007" 3 "2008" 4 "2009") region(color(white)) row(1))
	yti("Share of College Graduates" " ") xti(" " "Year of Graduation")
;# delimit cr
gr export "Results/Online Appendix/GraduationRatesAwardees.png", replace wid(2000) hei(1500)

/***************************************************************************************************
Appendix Figure D.1: RD Estimates as Function of the Bandwidth
****************************************************************************************************/
use "Results/Online Appendix/Data/BWRobustness.dta", clear

sum bw if MSEbw == 1 & RD_l != .
global hl_MSE = r(mean)
sum bw if MSEbw == 1 & RD_q != .
global hq_MSE = r(mean)

gen u95_l = RD_l + abs(invnormal(0.025))*SE_l
gen l95_l = RD_l - abs(invnormal(0.025))*SE_l
gen u95_q = RD_q + abs(invnormal(0.025))*SE_q
gen l95_q = RD_q - abs(invnormal(0.025))*SE_q

# delimit ;
twoway  (rspike u95_l l95_l bw if MSEbw != 1, lcolor(gs12))
		(scatter RD_l bw if MSEbw != 1, mcolor(white) msymbol(O) msize(small) mlw(thin))
		(scatter RD_l bw if MSEbw != 1, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(small) mlw(thin))
		,
		graphregion(color(white)) plotregion(lcolor(black))
		xlab(0.3(0.05)1, format(%9.2fc) labsize(small) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
		ylab(-0.2(0.05)0.4, format(%9.2fc) angle(0) labsize(small) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
		xli($hl_MSE, lcolor(black) lw(thin)) 
		yti("Effect on Log Earnings") xti(" " "Bandwidth")
		legend(off) 
; # delimit cr
gr export "Results/Online Appendix/RDbw_linear.png", replace wid(2000) hei(1500)
		
# delimit ;
twoway  (rspike u95_q l95_q bw if MSEbw != 1, lcolor(gs12))
		(scatter RD_q bw if MSEbw != 1, mcolor(white) msymbol(O) msize(small) mlw(thin))
		(scatter RD_q bw if MSEbw != 1, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(small) mlw(thin))
		,
		graphregion(color(white)) plotregion(lcolor(black))
		xlab(0.3(0.05)1, format(%9.2fc) labsize(small) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend) 
		ylab(-0.2(0.05)0.4, format(%9.2fc) angle(0) labsize(small) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
		xli($hq_MSE, lcolor(black) lw(thin)) 
		yti("Effect on Log Earnings") xti(" " "Bandwidth")
		legend(off) 
; # delimit cr
gr export "Results/Online Appendix/RDbw_quadratic.png", replace wid(2000) hei(1500)

/*********************************************************************************************************
Appendix Figure D.2: Robustness of the Effect of the National Award using Earnings between Ages 23 and 28
**********************************************************************************************************/
use "Results/Online Appendix/Data/RDRobust_alt",clear

gen main = 1 if bwmserd == 1 & model1 == 1 & covs == 1 & Areayear == 1

//Sort
gsort -beta
//Rank 
gen rank=_n
//Gen indicators and scatters
local scoff=" "
local scon=" "
local ind=-0.07
foreach var in nocovs Areayear Fieldyear scores covs model1 model2 bwmserd bwcerrd {
	cap gen i_`var' = `ind'
	local ind = `ind'-0.012

	if "`var'" == "bwcerrd" {
		global mlabel mlabel(bw) mlabpos(6) mlabcolor(black) mlabangle(0) mlabsize(tiny) mlabformat(%9.2fc)
	}
	else{
		global mlabel ""
	}

	local scoff = "`scoff' (scatter i_`var' rank, msize(vsmall) mcolor(gs14) $mlabel)" 
	local scon =" `scon' (scatter i_`var' rank if `var'==1, msize(vsmall) mcolor(black))"
		   
	if "`var'" == "model1" | "`var'" == "model2" {
		replace i_`var' = i_`var' - 0.03
	}
	if "`var'" == "bwmserd" | "`var'" == "bwcerrd" {
		replace i_`var' = i_`var' - 0.06
	}
}

# delimit ;
tw  (rspike u95 l95 rank, lcolor(gs5) lwidth(medthick))
	(rspike u90 l90 rank, lcolor(gs14) lwidth(medthick))
	(scatter beta rank if main==1, mcolor(white) msize(medium))
	(scatter beta rank if main!=1, mfcolor(gs12) mlcolor(black) msymbol(d) msize(medium) mlw(thin))
	`scoff' `scon'
	(scatter beta rank if main==1, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(medium) mlw(thin))
	,
	legend(order(4 "RD Estimates" 23 "Preferred Specification"  1 "95% CI" 2 "90% CI")
	region(lcolor(white)) pos(6) ring(1) rows(1) size(vsmall) symysize(small) symxsize(4pt))
	graphregion(fcolor(white) lcolor(white)) plotregion(fcolor(white) lcolor(white))
	xtitle(" ") ytitle(" ") yscale(noline) xscale(noline)
	ylab(0(0.05)0.3, format(%9.2fc) noticks nogrid angle(horizontal) labsize(small))
	yline(0, lp(shortdash) lcolor(black) lw(thin)) xlab("", noticks)  
;# delimit cr
global legend custom tickset(major) editstyle(tickstyle(textstyle(size(vsmall))))
gr_edit .yaxis1.add_ticks -0.05 `"Specification             "', $legend
gr_edit .yaxis1.add_ticks -0.07  `"No Controls   "', $legend
gr_edit .yaxis1.add_ticks -0.082 `"Area x Year FE   "', $legend
gr_edit .yaxis1.add_ticks -0.094 `"Field x Year FE   "', $legend
gr_edit .yaxis1.add_ticks -0.106 `"Test Scores   "', $legend
gr_edit .yaxis1.add_ticks -0.118 `"Covariates   "', $legend
gr_edit .yaxis1.add_ticks -0.14 `"Local Poly.                "', $legend
gr_edit .yaxis1.add_ticks -0.16 `"Linear            "', $legend
gr_edit .yaxis1.add_ticks -0.172 `"Quadratic      "', $legend
gr_edit .yaxis1.add_ticks -0.194 `"BW Method               "', $legend
gr_edit .yaxis1.add_ticks -0.214 `"MSE             "',$legend
gr_edit .yaxis1.add_ticks -0.226 `"CE                "', $legend
gr_edit .yaxis1.add_ticks -0.238 `"BW =            "', $legend
gr export "Results/Online Appendix/RDRobustness_alt.png", replace wid(2000) hei(1500)

/*********************************************************************************************************
Appendix Figure D.3: Robustness of the Effect of the National Distinction on Early-Career Earnings
**********************************************************************************************************/
use "Results/Online Appendix/Data/RDDropFields.dta", clear

gen low95 = RD - abs(invnormal(0.025))*SE
gen up95 = RD + abs(invnormal(0.025))*SE
gen low90 = RD - abs(invnormal(0.05))*SE
gen up90 = RD + abs(invnormal(0.05))*SE

gsort -RD
gen i = _n
labmask i, values(Field)

# delimit ;
tw 	(rspike up95 low95 i, lcolor(gs5))
	(rspike up90 low90 i, lcolor(gs14))
	(scatter RD i, mfcolor(white) mlcolor(white) msymbol(O) msize(medium))
	(scatter RD i, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(medium) mlw(thin))
	,
	legend(off)
	graphregion(color(white)) plotregion(lcolor(black))
	yli(0, lp(shortdash) lcolor(black) lw(thin)) 
	ylab(-0.05(0.05)0.20, format(%9.2f) angle(0) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	xlab(1(1)45, gmin gmax glwidth(thin) angle(90) glcolor(gs10) glpattern(dot) nogextend valuelabels labsize(small) )
	yti("Effect on Log Earnings")
	xti(" " "Field-Specific Exam")
;# delimit cr
gr export "Results/Online Appendix/RDDropFields.png", replace wid(2000) hei(1500)

/*******************************************************************************
Appendix Figure D.4: Persistence of the Effect on First τ Earnings
********************************************************************************/  
use "Results/Main/Data/RDDynamic_3.dta", clear

gen low95 = RD_balanced - abs(invnormal(0.025))*SE_balanced
gen up95 = RD_balanced + abs(invnormal(0.025))*SE_balanced
gen low90 = RD_balanced - abs(invnormal(0.05))*SE_balanced
gen up90 = RD_balanced + abs(invnormal(0.05))*SE_balanced

# delimit ;
tw 	(rspike up95 low95 t, lcolor(gs5))
	(rspike up90 low90 t, lcolor(gs14))
	(scatter RD_balanced t, mfcolor(white) mlcolor(white) msymbol(O) msize(medium))
	(scatter RD_balanced t, mfcolor("0 0 200%50") mlcolor("0 0 200") msymbol(O) msize(medium) mlw(thin))
	,
	legend(pos(6) order(4 "RD Estimates" 1 "95% CI" 2 "90% CI") row(1) region(color(white)))
	graphregion(color(white)) plotregion(lcolor(black))
	yli(0, lp(shortdash) lcolor(black) lw(thin)) 
	ylab(-0.05(0.05)0.25, format(%9.2f) angle(0) grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	xlab(1 "1ˢᵗ" 2 "2ⁿᵈ" 3 "3ʳᵈ" 4 "4ᵗʰ" 5 "5ᵗʰ", grid gmin gmax glwidth(thin) glcolor(gs10) glpattern(dot) nogextend)
	xscale(range(0.5 5.5))
	yti("Effect on {bf:{it:{&tau}-th}}" "Observed Log of Earnings")
	xti(" " "{bf:{it:{&tau}-th}} Observed Log of Earnings")
;# delimit cr
gr_edit .xaxis1.edit_tick 6 0.5 `" "', custom tickset(major) editstyle(tickstyle(linestyle(width(none))))
gr_edit .xaxis1.edit_tick 7 5.5 `" "', custom tickset(major) editstyle(tickstyle(linestyle(width(none))))
gr export "Results/Online Appendix/RDDynamic_3.png", replace wid(2000) hei(1500)

/*******************************************************************************
Appendix Figure F.1: Heterogeneous Effects of the Signal and Earnings Gaps
********************************************************************************/  
//Appendix Figure F.1 a
use "Results/Main/Data/RDHeterogeneity_cllg_rep_discrete.dta", clear

drop if Variable == 2
replace Variable = Variable - 1 if Variable > 1
replace Order = Order - 3 if Variable > 1

# delimit ;
local header1 (scatteri 0.39 0.25 0.39 2.75, recast(line) lcolor(black) lwidth(medium) 
	text(0.421 1.5 "Parents'", size(medsmall)) text(0.40 1.5 "Education", size(medsmall)) 
	text(0.38 0.95 "Non-", size(small)) text(0.365 0.95 "College", size(small)) 	
	text(0.37 2.05 "College", size(small))
	text(0.34 1 "(1)", size(small)) text(0.34 2 "(2)", size(small)) )
;# delimit cr

# delimit ;
local header2 (scatteri 0.39 3.25 0.39 5.75, recast(line) lcolor(black) lwidth(medium)
	text(0.421 4.5 "College", size(medsmall)) text(0.40 4.5 "Networks", size(medsmall))
	text(0.37 3.95 "Low", size(small)) text(0.37 5.05 "High", size(small))
	text(0.34 4 "(1)", size(small)) text(0.34 5 "(2)", size(small)) )
;# delimit cr

# delimit ;
local header3 (scatteri 0.39 6.25 0.39 8.75, recast(line) lcolor(black) lwidth(medium)
	text(0.41 7.5 "Gender", size(medsmall))
	text(0.37 7 "Female", size(small)) text(0.37 8 "Male", size(small))
	text(0.34 7 "(1)", size(small)) text(0.34 8 "(2)", size(small)) )
	(scatteri 0.35 0.6 0.35 1.4, recast(line) lcolor(black) lwidth(medium)) 
	(scatteri 0.35 1.6 0.35 2.4, recast(line) lcolor(black) lwidth(medium)) 
	(scatteri 0.35 3.6 0.35 4.4, recast(line) lcolor(black) lwidth(medium))
	(scatteri 0.35 4.6 0.35 5.4, recast(line) lcolor(black) lwidth(medium))
	(scatteri 0.35 6.6 0.35 7.4, recast(line) lcolor(black) lwidth(medium))
	(scatteri 0.35 7.6 0.35 8.4, recast(line) lcolor(black) lwidth(medium))
;# delimit cr
	
# delimit ;
tw (bar Coeff Order, barw(0.75) bfcolor("0 0 200%50") lcolor("0 0 200"))
   (rcap low95 up95 Order, color(black)) `header1' `header2' `header3'
   (scatter Coeff Order, msymbol(none) mlab(Coeff) mlabformat(%9.2f) mlabpos(2) mlabcolor(black))
   ,
	yti("Effect on Log Earnings" " ") xti("") graphregion(color(white))
	ylab(-0.10(0.05)0.4, angle(0) format(%9.2f) nogrid) yli(0, lcolor(black) lw(thin))
	xla(0(1)9, nolabels notick nogrid) xscale(noline)
	legend(pos(6) order(1 "RD Estimates" 2 "95% CI") region(color(white)) row(1))
;# delimit cr
gr export "Results/Main/Heterogeneity_cllg_rep_discrete.png", replace wid(2000) hei(1500)

//Appendix Figure F.1 b

use "Results/Online Appendix/Data/Gaps.dta", clear

drop if Variable == 2
replace Variable = Variable - 1 if Variable > 1
replace Order = Order - 3 if Variable > 1

# delimit ;
local header1 (scatteri 0.385 0.25 0.385 2.75, recast(line) lcolor(black) lwidth(medium)
	text(0.43 1.5 "Parents'", size(medsmall)) text(0.405 1.5 "Education", size(medsmall))
	text(0.37 0.9 "(1)", size(small)) text(0.37 1.5 "(2)", size(small)) text(0.37 2.1 "(3)", size(small)))
;# delimit cr
	
# delimit ;
local header2 (scatteri 0.385 3.25 0.385 5.75, recast(line) lcolor(black) lwidth(medium)
	text(0.43 4.5 "College", size(medsmall)) text(0.405 4.5 "Networks", size(medsmall))
	text(0.37 3.9 "(1)", size(small)) text(0.37 4.5 "(2)", size(small)) text(0.37 5.1 "(3)", size(small)))
;# delimit cr

# delimit ;
local header3 (scatteri 0.385 6.25 0.385 8.75, recast(line) lcolor(black) lwidth(medium)
	text(0.41 7.5 "Gender", size(medsmall))
	text(0.37 6.9 "(1)", size(small)) text(0.37 7.5 "(2)", size(small)) text(0.37 8.1 "(3)", size(small)))
;# delimit cr
	
# delimit ;
tw (bar Coeff Order if Category == 1, barw(0.5) bfcolor(gs3%30) lcolor(gs3) lp(shortdash) )
   (bar Coeff Order if Category == 2, barw(0.5) bfcolor("0 0 200%40") lcolor("0 0 200") )
   (bar Coeff Order if Category == 3, barw(0.5) bfcolor("255 0 0%40") lw(none))   (rcap low95 up95 Order, color(black)) `header1' `header2' `header3'
   (scatter Coeff Order if Category == 1 & Variable != 2, msymbol(none) mlab(Coeff) mlabformat(%9.2f) mlabpos(8) mlabcolor(black)) 
   (scatter Coeff Order if Category == 1 & Variable == 2, msymbol(none) mlab(Coeff) mlabformat(%9.2f) mlabpos(9) mlabcolor(black)) 
   (scatter Coeff Order if Category == 2, msymbol(none) mlab(Coeff) mlabformat(%9.2f) mlabpos(1) mlabcolor(black))
   (scatter Coeff Order if Category == 3 & Variable != 3, msymbol(none) mlab(Coeff) mlabformat(%9.2f) mlabpos(4) mlabcolor(black)) 
   (scatter Coeff Order if Category == 3 & Variable == 3, msymbol(none) mlab(Coeff) mlabformat(%9.2f) mlabpos(2) mlabcolor(black)) 
   ,
	yti("Effect on Log Earnings" " ") xti("") graphregion(color(white))
	ylab(-0.2(0.05)0.4, angle(0) format(%9.2f) nogrid) yli(0, lcolor(black) lw(thin))
	xlab(0(1)9, nolabels notick nogrid) xscale(noline)
	legend(pos(6) order(1 "No Signal" 2 "One side signals" 3 "Both sides signal" 4 "95% CI") region(color(white)) row(1) size(small) symysize(2pt) symxsize(6pt) colgap(1pt) keygap(0.2pt))
;# delimit cr
gr export "Results/Online Appendix/Gaps.png", replace wid(700) hei(500)


/*******************************************************************************
Appendix Tables
********************************************************************************/

/*******************************************************************************
Appendix Table A.1: Eligibility to Take the College Exit Exam by Cohort
********************************************************************************/  

use "Data\Finals\SProEligible.dta", clear

rename spa_spro exam 
rename prim_year cohort
gen exam_0609 = exam_year>= 2006 & exam_year <= 2009 

gen N = 1
collapse (sum) N exam exam_0609, by(cohort)

tostring cohort, replace

count 
local N = r(N)+1
set obs `N'

foreach var of varlist N exam exam_0609 {
	gen aux = sum(`var')
	replace `var' = aux if `var' == .
	drop aux
}

gen perc = exam*100/N
gen perc_0609 = exam_0609*100/N

tostring N exam*, format(%9.0fc) replace force
tostring perc*, format(%9.2fc) replace force

replace cohort = "\addlinespace Total" if cohort == ""
replace cohort = "\addlinespace 2002" if cohort == "2002"

order cohort N exam_0609 perc_0609 exam perc

# delimit ;
texsave cohort N exam_0609 perc_0609 exam perc using "Results/Online Appendix/EligDescr.tex",
headerlines("
& & \multicolumn{4}{c}{Students Taking College Exit Exam:} \\\cline{3-6}\addlinespace
Cohort of Enrollment & Eligible Students & From 2006 to 2009 & \% & Overall & \% \\\cline{1-1}\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6}\addlinespace
& (1) & (2) & (3) & (4) & (5)
") 
replace align(c@{\extracolsep{4pt}}ccccc) location(h) frag nonames nofix  
; # delimit cr
tex_edits, file("Results/Online Appendix/EligDescr.tex")


/***************************************************************************************************
Appendix Table A.2: Probability of Taking the College Exit Exam
****************************************************************************************************/
use "Results/Online Appendix/Data/ProbSaberPro_dta", clear

// Modify
drop in 1/3
replace v1 = "\addlinespace High School Exam Scores" if v1=="puntaje_icfes"
replace v1 = "Top 5 College" if v1=="top5"
replace v1 = "Top 6-20 College" if v1=="top20"
replace v1 = "Private College" if v1=="cllg_prv"
replace v1 = "Female" if v1=="female"
replace v1 = "Age at Enrollment" if v1=="age"
replace v1 = "High SES" if v1=="high_SES"

gen n = _n
replace n = 2 + n/19 if n >= 13 & n <= 18
drop if n >= 9 & n <= 12
sort n

// Export
# delimit ;
texsave v1-v7 using "Results/Online Appendix/ProbSaberPro.tex",
headerlines("
& \multicolumn{6}{c}{Dependent Variable : Took College Exit Exam}\\ \cline{2-7} \addlinespace
& (1) & (2) & (3) & (4) & (5) & (6)
") 
replace align(l@{\extracolsep{4pt}}ccccccc) location(h) frag nonames nofix 
; # delimit cr
tex_edits, file("Results/Online Appendix/ProbSaberPro.tex")

/***************************************************************************************************
Appendix Table A.3: Description of Students Around Threshold
by Field-Specific Exam
****************************************************************************************************/
preserve
use "Data/Finals/Estimation Sample.dta", clear
keep if exam_time <= 20092
keep if sample == 1

tab award if abs(score_sd) < abs($MSE_Bw)
gen AroundT = (score_sd>0) if abs(score_sd) < abs($MSE_Bw)
gen above = (score_sd>=0)
gen below = score_sd<0

gen around_=1 
collapse (sum) around_ below above, by(exam_field area AroundT)
decode area, gen(exam_area)
drop area
replace AroundT = 2 if AroundT == .
reshape wide around_ below above, i(exam_field exam_area) j(AroundT)

order exam_field exam_area around_? below? above?

egen below = rowtotal(below*)
drop below?
egen above = rowtotal(above*)
drop above?
drop around_2

gen total = below + above

replace exam_area = subinstr(exam_area, "Sciences", "Sc.", .)
replace exam_area = "Social Sc." if exam_area == "Social Sc."
replace exam_area = "Business \& Econ" if regexm(exam_area, "Econ")
sort exam_area exam_field

order exam_field exam_area total below above around_0 around_1
tostring total below above around_0 around_1, replace format(%9.0fc) force

// Export
# delimit ;	
texsave exam_field exam_area total above around_1 around_0 using "Results/Online Appendix/ObsByField.tex",
headerlines("
\multicolumn{1}{c}{\multirow{2}{*}{Exam Field}} & \multirow{2}{*}{Area} & \multirow{2}{*}{Test Takers} & \multirow{2}{*}{Awardees} & \multicolumn{2}{c}{MSE-Bandwidth} \\\cline{5-6} \addlinespace
 & & & & Awardees & Non-Awardees \\\cline{1-1}\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6}
 & & (1) & (2) & (3) & (4) \\\addlinespace
") 
replace align(l@{\extracolsep{4pt}}ccccc) location(h) frag nonames nofix  
; # delimit cr
tex_edits, file("Results/Online Appendix/ObsByField.tex")
restore

/*******************************************************************************
Appendix Table A.4: Description of Estimation Sample by College Ranking
********************************************************************************/
use "Data/Finals/Estimation Sample.dta", clear

gen catranking = top5
replace catranking = 2 if top20==1
replace catranking = 3 if above20==1

gen one = 1
egen total = sum(one), by(cllg_code)
gen double w_cllg = one/total
drop one total 

// Compute Statistics

tab cllg_prv catranking [iw=w_cllg], m matcell(mat1)

mat mat2 = J(1,3,.)
foreach  i of numlist 1(1)3 {
unique exam_id if catranking == `i'
mat mat2[1, `i'] = 	r(unique)
}
unique exam_id
local F = r(unique)

tab exam_year catranking, matcell(mat3)

tab cllg_prv catranking if award==1, matcell(mat4)
	
// Create Matrices
mat M = J(1,3,.) \mat1 \ mat2 \ J(1,3,.) \  mat3 \ J(1,3,.) \ mat4
clear
svmat M
// Edit Variables
gen 	names = "\addlinespace\hspace{5pt} Public Universities"  in 2
replace names = "\hspace{5pt} Private Universities" in 3
replace names = "\hspace{5pt} Field Exams"  in 4
replace names = "\addlinespace\hspace{5pt} 2006"  in 6
replace names = "\hspace{5pt} 2007"  in 7
replace names = "\hspace{5pt} 2008"  in 8
replace names = "\hspace{5pt} 2009"  in 9
replace names = "\addlinespace\hspace{5pt} Public  University"  in 11
replace names = "\hspace{5pt} Private University"  in 12

replace names =  "\textit{Number of:}"   in 1
replace names =  "\addlinespace\textit{Number of Test Takers per Year:}" in 5
replace names =  "\addlinespace\textit{Number of Awardees:}"    in 10
	
egen M4 = rowtotal(M1 M2 M3) if names!=""
replace M4 = `F' in 4
replace M4 = . if M4 == 0
	
br names M1-M4
tostring M1-M4, replace format(%9.0fc) force
forvalues i = 1/4 {
	replace M`i' = "" if M`i' =="." 
}

order names M1 M2 M3 M4

// Export
# delimit ;	
texsave names M1 M2 M3 M4 using "Results/Online Appendix/DescCllg.tex",
headerlines("
& Top 5 & Top 6-20 & Above 20 & Total \\\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\addlinespace
& (1) & (2) & (3) & (4)
") 
replace align(l@{\extracolsep{4pt}}cccc) location(h) frag nonames nofix  
; # delimit cr
tex_edits, file("Results/Online Appendix/DescCllg.tex")

/*******************************************************************************
Appendix Table A.5: Awardee Characteristics by Area
********************************************************************************/
use "Results/Online Appendix/Data/AwardeeCharacteristics.dta", clear
gen var = "", before(A1)
replace var = "Female" in 1
replace var = "Age at Test Date" in 2
replace var = "High College Network" in 3
replace var = "Low-Socioeconomic Status" in 4
replace var = "First Generation College Student" in 5
replace var = "Mother Educ: College" in 6
replace var = "Father Educ: College" in 7
replace var = "Working at Test Date" in 8
replace var = "Private College" in 9
replace var = "College Ranking: 1-5" in 10
replace var = "College Ranking: 6-20" in 11
replace var = "College Ranking: 20 or below" in 12
replace var = "Semesters in College" in 13
replace var = "High School Score" in 14
replace var = "English Score" in 15
replace var = "Reading Score" in 16
tostring A*, replace force format(%9.2fc)
drop in 13/16
drop in 8

// Export
# delimit ;	
texsave var A* using "Results/Online Appendix/AwardeeCharacteristics.tex", 
headerlines("
& \multicolumn{7}{c}{Means}\\ \cline{2-8} \addlinespace
& \multirow{2}{*}{Overall} & Agricultural & \multirow{2}{*}{Health} & Social & Business and & \multirow{2}{*}{Engineering} & Math and \\ 
&  & Sciences & & Sciences & Economics & & Sciences \\ 
\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6}\cline{7-7}\cline{8-8} \addlinespace
& (1) & (2) & (3) & (4) & (5) & (6) & (7) \\
") 
replace align(l@{\extracolsep{4pt}}ccccccc) location(h) frag nonames nofix 
; # delimit cr
tex_edits, file("Results/Online Appendix/AwardeeCharacteristics.tex")

/*******************************************************************************
Appendix Table B.1: Description of the Estimation Sample
********************************************************************************/

* See 2. Appendix_Analysis

/*******************************************************************************
Appendix Table B.2: Summary Statistics of College Exit Exam Test-Takers, 2006-2009
********************************************************************************/
use "Results/Online Appendix/Data/Statistics_dta", clear
sum A3 
local N1 = r(mean)
sum B3
local N2 = r(mean)
sum C3
local N3 = r(mean)

// Modify
replace variable = "\hspace{8pt} National Award" in 1
replace variable = "\hspace{8pt} Female" in 2
replace variable = "\hspace{8pt} Age at Exam Date" in 3
replace variable = "\hspace{8pt} Socioeconomic Stratum" in 4
replace variable = "\hspace{8pt} Mother's Educ: HS" in 5
replace variable = "\hspace{8pt} Mother's Educ: College" in 6
replace variable = "\hspace{8pt} Mother's Educ: Graduate" in 7
replace variable = "\hspace{8pt} Private College" in 8
replace variable = "\hspace{8pt} Top 5 College" in 9
replace variable = "\hspace{8pt} Top 6-20" in 10
replace variable = "\hspace{8pt} Agricultural Sciences" in 11
replace variable = "\hspace{8pt} Health" in 12
replace variable = "\hspace{8pt} Social Sciences" in 13
replace variable = "\hspace{8pt} Business and Economics" in 14
replace variable = "\hspace{8pt} Engineering" in 15
replace variable = "\hspace{8pt} Math and Natural Sc." in 16
drop *3

foreach var of varlist A* B* C* {
   replace `var' = round(`var', 0.01)
   format `var' %9.2fc
}

gen sort = _n
insobs 3
replace variable = "\textit{Individual Characteristics} :" in 17 
replace variable = "\textit{College Characteristics} : " in 18
replace variable = "\textit{Area of Study} :" in 19
replace sort = 0.5 in 17
replace sort = 7.5 in 18
replace sort = 10.5 in 19
sort sort

// Export
# delimit ;	
texsave variable-C2 using "Results/Online Appendix/Statistics.tex",
headerlines("
&\multicolumn{2}{c}{Main Sample} & \multicolumn{2}{c}{Industry Sample} & \multicolumn{2}{c}{Firms Sample} \\
&\multicolumn{2}{c}{(\emph{N} = `N1')} & \multicolumn{2}{c}{(\emph{N} = `N2')} & \multicolumn{2}{c}{(\emph{N} = `N3')} \\\cline{2-3}\cline{4-5}\cline{6-7} \addlinespace
&Mean&Std. Dev.&Mean&Std. Dev.&Mean&Std. Dev. \\\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6}\cline{7-7} \addlinespace
& (1) & (2) & (3) & (4) & (5) & (6)
") 
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix 
; # delimit cr
tex_edits, file("Results/Online Appendix/Statistics.tex")

/*******************************************************************************
Appendix Table C.1: Months from College Exit Exam and Graduation Date to First Observed Earnings
********************************************************************************/
use "Results/Online Appendix/Data/MonthsToEarnings_dta", clear

// Modify
drop in 4/7
drop in 1/2
replace v1 = "National Award" if v1=="Robust"

foreach i of numlist 2(1)7{
    replace v`i' = "" if v`i' == "No"
}

gen n = _n
replace n = n + 7 if n >= 6 & n <= 8
sort n

// Export
# delimit ;	
texsave v* using "Results/Online Appendix/MonthsToEarnings.tex", 
headerlines("
& \multicolumn{6}{c}{Dependent Variable : Log of Months to Observed Earnings} \\\cline{2-7} \addlinespace 
& \multicolumn{3}{c}{Months From Exam Date} & \multicolumn{3}{c}{Months From Graduation Date} \\\cline{2-4}\cline{5-7} \addlinespace 
& (1) & (2) & (3) & (4) & (5) & (6)
") 
replace align(l@{\extracolsep{4pt}}cccccccc) location(h) frag nonames nofix
; # delimit cr
// Final Edits
tex_edits, file("Results/Online Appendix/MonthsToEarnings.tex")

/*******************************************************************************
Appendix Table D.1: Effect of the National Award on Different Measures of Early-Career Earnings
********************************************************************************/
use "Results/Online Appendix/Data/RDRobust.dta", clear

gen n = _n
drop if n >= 4 & n <= 7
drop if n >= 12 & n <= 15
drop if n >= 22 & n <= 25
drop if n >= 30 & n <= 33
drop if n >= 40 & n <= 43
drop if n == 3 | n == 21
replace n = . if n == 39
replace n = 3 if n == 1 
replace n = 21 if n == 19 
replace n = 39 if n == 37
replace n = 37 if n == .

sum n
replace n = r(max) + n/r(max) if (n >= 48 & n <= 51) | n == 37
sort n

replace v1 = "\textit{Panel A :}" if n == 2 
replace v2 = "\multicolumn{6}{c}{Log First Observed Earnings}" if v2 == "ln_earningsMW"

replace v1 = "\cline{2-7}\\ \textit{Panel B :}" if n == 20
replace v2 = "\multicolumn{6}{c}{Log Earnings One Year After Graduation}" if v2 == "ln_earningsMW_1"

replace v1 = "\cline{2-7}\\ \textit{Panel D :}" if n == 38
replace v2 = "\multicolumn{6}{c}{Log Avg. Earnings Age 23 to 28}" if v2 == "ln_earningsMW_23_28"

local i = 2
foreach var of varlist v2-v7 {
	replace `var' = "" if regexm(`var', "earnings") 
	replace `var' = "" if `var' == "No"
local i = `i'+1
}

replace v1 = "\addlinespace National Award" if v1 == "Robust"
replace v1 = "\cline{2-7}\addlinespace" if v1[_n+1] == "\addlinespace National Award" & v1 == ""

// Export
# delimit ;	
texsave v* using "Results/Online Appendix/RDRobust.tex", 
headerlines("
& \multicolumn{6}{c}{Dependent Variable : } \\\cline{2-7} 
") 
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix
; # delimit cr
// Final Edits
tex_edits, file("Results/Online Appendix/RDRobust.tex")
sleep 200
replace_tex "Results/Online Appendix/RDRobust.tex" "&&&&&" " "
sleep 200
replace_tex "Results/Online Appendix/RDRobust.tex" "cline{2--7}" "cline{2-7}"

/***************************************************************************************************
Appendix Table D.2: Robustness: Effect of National Distinction Award on Early-Career Earnings, Excluding 2006 Test-Takers
****************************************************************************************************/
use "Results/Online Appendix/Data/RDMain_No2006_dta", clear
// Modify
gen n = _n
drop if n >= 1 & n<=7
replace n = 11 + n/19 if n>= 16
sort n

replace v1 = "National Award" if v1=="Robust"
foreach var of varlist v2-v7{
	replace `var' = "" if `var' == "No"
}

//Some Edits
replace v1 = "\addlinespace " + v1 if regexm(v1, "Area")

// Export
# delimit ;	
texsave v1-v7 using "Results/Online Appendix/RDMain_No2006.tex", 
headerlines("
& \multicolumn{6}{c}{Dependent Variable : Log Earnings}\\ \cline{2-7} \addlinespace
& (1) & (2) & (3) & (4) & (5) & (6)
") 
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix 
; # delimit cr
tex_edits, file("Results/Online Appendix/RDMain_No2006.tex")

/***************************************************************************************************
Appendix Table D.3: Robustness of the Effect of the National Distinction on Early-Career Earnings
****************************************************************************************************/
use "Results/Online Appendix/Data/RDNoSmallFields_dta", clear
// Modify
gen n = _n
drop if n >= 1 & n<=7
replace n = 11 + n/19 if n>= 16
sort n

replace v1 = "National Award" if v1=="Robust"
foreach var of varlist v2-v7{
	replace `var' = "" if `var' == "No"
}

//Some Edits
replace v1 = "\addlinespace " + v1 if regexm(v1, "Area")

// Export
# delimit ;	
texsave v1-v7 using "Results/Online Appendix/RDNoSmallFields.tex", 
headerlines("
& \multicolumn{6}{c}{Dependent Variable : Log Earnings}\\ \cline{2-7} \addlinespace
& (1) & (2) & (3) & (4) & (5) & (6)
") 
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix 
; # delimit cr
tex_edits, file("Results/Online Appendix/RDNoSmallFields.tex")

/***************************************************************************************************
Appendix Table D.4: Robustness: Effect of National Distinction Award on Early-Career Earnings, Excluding Fields with less than 10 Awards
****************************************************************************************************/
use "Results/Online Appendix/Data/RDMain_10APF_dta", clear
// Modify
gen n = _n
drop if n >= 1 & n<=7
replace n = 11 + n/19 if n>= 16
sort n

replace v1 = "National Award" if v1=="Robust"
foreach var of varlist v2-v7{
	replace `var' = "" if `var' == "No"
}

//Some Edits
replace v1 = "\addlinespace " + v1 if regexm(v1, "Area")

// Export
# delimit ;	
texsave v1-v7 using "Results/Online Appendix/RDMain_10APF.tex", 
headerlines("
& \multicolumn{6}{c}{Dependent Variable : Log Earnings}\\ \cline{2-7} \addlinespace
& (1) & (2) & (3) & (4) & (5) & (6)
") 
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix 
; # delimit cr
tex_edits, file("Results/Online Appendix/RDMain_10APF.tex")

/***************************************************************************************************
Appendix Table D.5: Effect of the National Distinction Award on Earnings Using the Ranking of Scores as Running Variable
****************************************************************************************************/
use "Results/Online Appendix/Data/RDRank_dta", clear

// Modify
gen n = _n
drop if n >= 1 & n <= 3
drop if n >= 6 & n <= 9
replace n = 10.5 if n == 12
sort n

replace v1 = "\addlinespace National Award" if v1=="award"
replace v1 = "\addlinespace Area x Year FE" if v1=="Area x Year FE"

foreach i of numlist 2(1)9{
    replace v`i' = "" if v`i' == "No"
}


// Export
# delimit ;	
texsave v* using "Results/Online Appendix/RDEarningsRank.tex", 
headerlines("
& \multicolumn{8}{c}{Dependent Variable : Log Earnings} \\\cline{2-9} \addlinespace 
& (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8)
") 
replace align(l@{\extracolsep{4pt}}cccccccc) location(h) frag nonames nofix
; # delimit cr
// Final Edits
tex_edits, file("Results/Online Appendix/RDEarningsRank.tex")

/*******************************************************************************
Appendix Table D.6: Robustness: Effect of National Distinction Award on Rarly-Career Earnings, Excluding Fields Rejected by Manipulation Test
********************************************************************************/
use "Results/Online Appendix/Data/RDMain_NoManipulation_dta", clear
// Modify
gen n = _n
drop if n >= 1 & n<=7
replace n = 11 + n/19 if n>= 16
sort n

replace v1 = "National Award" if v1=="Robust"
foreach var of varlist v2-v7{
	replace `var' = "" if `var' == "No"
}

//Some Edits
replace v1 = "\addlinespace " + v1 if regexm(v1, "Area")

// Export
# delimit ;	
texsave v1-v7 using "Results/Online Appendix/RDMain_NoManipulation.tex", 
headerlines("
& \multicolumn{6}{c}{Dependent Variable : Log Earnings}\\ \cline{2-7} \addlinespace
& (1) & (2) & (3) & (4) & (5) & (6)
") 
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix 
; # delimit cr
tex_edits, file("Results/Online Appendix/RDMain_NoManipulation.tex")

/*******************************************************************************
Appendix Table E.1: National Distinction Award and College Reputation
********************************************************************************/
use "Results/Online Appendix/Data/CollegeReputationBw_dta", clear
// Modify
drop in 1/7
drop in 5
replace v1 = "\addlinespace National Award" if v1=="Robust"

foreach var of varlist v8-v13{
	replace `var' = substr(`var', 1, 5) if v1 == "Mean Control"
}

// Export
# delimit ;	
texsave v1-v7 using "Results/Online Appendix/CollegeReputationBw.tex",
headerlines("
& \multicolumn{6}{c}{Dependent Variable : Log Earnings} \\\cline{2-7} \addlinespace 
&  & \multicolumn{3}{c}{College Ranking :} & \multicolumn{2}{c}{Cross-sample Comparison :} \\\cline{3-5}\cline{6-7} \addlinespace 
& Full & & & & \multicolumn{2}{c}{Top 5 Non-awardees vs.}\\\cline{6-7}\addlinespace 
& \multirow{-2}{*}{Sample} & \multirow{-2}{*}{Top 5} & \multirow{-2}{*}{Top 6-20} & \multirow{-2}{*}{Below 20} & Top 6-20 & Below 20 \\ 
& & & & & Awardees & Awardees \\\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6}\cline{7-7}\addlinespace 
& (1) & (2) & (3) & (4) & (5) & (6)
")
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix 
; # delimit cr
// Final Edits
tex_edits, file("Results/Online Appendix/CollegeReputationBw.tex")

/*******************************************************************************
Appendix Table E.2: Effects on the Allocation of Skills
********************************************************************************/
use "Results/Online Appendix/Data/FieldIndustryBw_dta", clear
// Modify
drop in 4/7
replace v1 = "National Award" if v1=="Robust"
drop in 1/2
// Export
# delimit ;	
texsave v1-v7 using "Results/Online Appendix/FieldIndustryBw.tex", 
headerlines("
& \multicolumn{6}{c}{Dependent Variable : } \\\cline{2-7} \addlinespace 
& \multicolumn{4}{c}{Field-Industry Match} & \multicolumn{2}{c}{Log Earnings} \\\cline{2-5}\cline{6-7} \addlinespace 
& \multirow{2}{*}{Full} & \multicolumn{3}{c}{College Ranking :} & \multicolumn{2}{c}{Type of Skills :} \\\cline{3-5}\cline{6-7} \addlinespace 
& Sample & Top 5 & Top 6-20 & Below 20 & Specific & Transferable \\ \addlinespace \cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6}\cline{7-7} \addlinespace 
& (1) & (2) & (3) & (4) & (5) & (6) 
") 
replace align(l@{\extracolsep{4pt}}cccccc) location(h) frag nonames nofix
; # delimit cr
// Final Edits
tex_edits, file("Results/Online Appendix/FieldIndustryBw.tex")

/*******************************************************************************
Appendix Table E.3: Effects on the Match Probability with High-Productivity Firms
********************************************************************************/
use "Results/Online Appendix/Data/FirmProductivityBw_dta", clear		
// Modify
drop in 4/7
replace v1 = "National Award" if v1=="Robust"
drop in 1/2		
// Table
# delimit ;	
texsave v1-v5 using "Results/Online Appendix/FirmProductivityBw.tex",
headerlines("
& \multicolumn{4}{c}{Dependent Variable : Employer's Wage Premium}\\ \cline{2-5} \addlinespace 
& \multicolumn{2}{c}{First Employer} & \multicolumn{2}{c}{Avg. Across Employers} \\ \cline{2-3} \cline{4-5} \addlinespace 
& Unconditional & AKM & Unconditional & AKM \\ 
& Ranking & Ranking & Ranking & Ranking \\\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5} \addlinespace 
& (1) & (2) & (3) & (4)
") 
replace align(l@{\extracolsep{4pt}}cccc) location(h) frag nonames nofix 
;# delimit cr
tex_edits, file("Results/Online Appendix/FirmProductivityBw.tex")

/*******************************************************************************
Appendix Table E.4: Effects on Human Capital Accumulation
********************************************************************************/
use "Results/Online Appendix/Data/HumanCapitalBw_dta", clear
// Modify
drop in 4/7
replace v1 = "National Award" if v1=="Robust"
drop in 1/2
// Export
# delimit ;	
texsave v* using "Results/Online Appendix/HumanCapitalBw.tex",
headerlines("
& \multicolumn{5}{c}{Dependent Variable : } \\\cline{2-6} \addlinespace 
& \multirow{2}{*}{Months to} & \multicolumn{3}{c}{Number of Subjects by Graduation} & \multirow{2}{*}{Graduate} \\\cline{3-5} \addlinespace
& College & Total & \multicolumn{2}{c}{Registered After Exam:} & Education \\\cline{4-5} \addlinespace
& \multirow{-2}{*}{Grad. Date} & \multirow{-2}{*}{Registered} & Total & Passed & \\\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\cline{6-6} \addlinespace
& (1) & (2) & (3) & (4) & (5)
") 
replace align(l@{\extracolsep{4pt}}ccccc) location(h) frag nonames nofix
; # delimit cr
tex_edits, file("Results/Online Appendix/HumanCapitalBw.tex")

/*******************************************************************************
Appendix Table E.5: Effects on the Probability of Switching Jobs and Job Characteristics After Switching
********************************************************************************/
use "Results/Online Appendix/Data/Job-LadderBW_P1_dta", clear
gen n = _n
drop if n >= 4 & n <= 7
drop if n >= 11 & n <= 15
drop n
append using "Results/Online Appendix/Data/Job-LadderBW_P2_dta"
gen n = _n
drop if n >= 7 & n <= 13

replace v1 = "National Award" if v1=="Robust"
drop in 1/2
replace v1 = "\addlinespace \textit{Linear Polynomial}" if n == 3
replace v1 = "\addlinespace \textit{Quadratic Polynomial}" if n == 6

// Export
# delimit ;	
texsave v* using "Results/Online Appendix/Job-LadderBw.tex",
headerlines("
& \multicolumn{7}{c}{Dependent Variable : } \\\cline{2-8} \addlinespace
& \multicolumn{2}{c}{Worker Switch} & \multicolumn{5}{c}{Employer's Wage Premium Across Time, $\tau$} \\\cline{4-8} \addlinespace
& \multicolumn{2}{c}{\multirow{-2}{*}{Employers}} & \multicolumn{3}{c}{First Employer} & \multicolumn{2}{c}{$\Delta$ Future Employers} \\\cline{2-3}\cline{4-6}\cline{7-8} \addlinespace 
& Once & Twice & \multicolumn{3}{c}{$\tau$ = 1} & $\tau = 2$ & $\tau = 3$ \\\cline{2-2}\cline{3-3}\cline{4-6}\cline{7-7}\cline{8-8} \addlinespace 
& (1) & (2) & (3) & (4) & (5) & (6) & (7)
") 
replace align(l@{\extracolsep{4pt}}ccccccc) location(h) frag nonames nofix 
; # delimit cr
tex_edits, file("Results/Online Appendix/Job-LadderBw.tex")

/*******************************************************************************
Appendix Table G.1: Effects on Allocation of Skills Using Different Measures
********************************************************************************/
use "Results/Online Appendix/Data/FieldIndustryRobust2", clear

gen n = _n
drop if n >= 4 & n <= 7
drop if n >= 19 & n <= 22
drop if n == 3 | n == 18
replace n = 3 if n == 1
replace n = 18 if n == 16
expand 3 in 15
replace n = 1 in 21
replace n = 16 in 22
sort n

replace v1 = "\textit{Panel A :}" if n == 1 
replace v1 = "\cline{2-5} \addlinespace \textit{Panel B :}" if n == 16
replace v2 = "Researcher 1" if regexm(v2, "CIIUMatch")
replace v3 = "Researcher 2" if regexm(v3, "CIIUMatch")
replace v4 = "Union" if regexm(v4, "CIIUMatch")
replace v5 = "Overlap" if regexm(v5, "CIIUMatch")
replace v1 = "\addlinespace National Award" if v1 == "Robust"
replace v2 = "\multicolumn{4}{c}{First Industry of Employment}" if n == 1
replace v2 = "\multicolumn{4}{c}{Any Industry of Employment After Graduation}" if n == 16
replace v1 = "\cline{2-5}\addlinespace" if v1 == "VARIABLES"
replace v1 = "\cline{2-2}\cline{3-3}\cline{4-4}\cline{5-5}\addlinespace" if n == 3 | n == 18

// Export
# delimit ;	
texsave v1-v5 using "Results/Online Appendix/FieldIndustryRobust2.tex", 
headerlines("
& \multicolumn{4}{c}{Dependent Variable : Field-Industry Match}\\ \cline{2-5}
") 
replace align(l@{\extracolsep{4pt}}cccc) location(h) frag nonames nofix
; # delimit cr
tex_edits, file("Results/Online Appendix/FieldIndustryRobust2.tex")
sleep 200
replace_tex "Results/Online Appendix/FieldIndustryRobust2.tex" "&&&" " "
sleep 200
replace_tex "Results/Online Appendix/FieldIndustryRobust2.tex" "cline{2--5}" "cline{2-5}"
sleep 200
replace_tex "Results/Online Appendix/FieldIndustryRobust2.tex" "\BScline{2-5}  \BStabularnewline" "\BScline{2-5} \BSaddlinespace"
